class Solution:
    def diffWaysToCompute(self, input: str) -> list:
        """这个解法实在有点想不下去了"""
        input_list = list(input)
        num_kuohao = len(input_list) // 2
        if num_kuohao <= 1:
            return [eval(input)]
        input_list.insert(0, "")
        input_list.append("")
        # print(input_list, num_kuohao)
        # kuohao_list = [[0, 4]] * num_kuohao
        # while True:
        #     for i in range(1, num_kuohao):
        #         kuohao_list[i][0], kuohao_list[i][1] = kuohao_list[i-1][0], kuohao_list[i-1][1] + 2


class Solution:
    def diffWaysToCompute(self, input: str) -> list:
        if len(input) <= 2:
            return [int(input)]
        res = []
        mid_set = {"+", "-", "*"}
        for index in range(1, len(input)):
            if input[index] in mid_set:
                left_list = self.diffWaysToCompute(input[:index])
                right_list = self.diffWaysToCompute(input[index+1:])
                # res.extend([eval(str(i) + input[index] + str(j)) for i in left_list for j in right_list])
                if input[index] == "+":
                    res.extend([i + j for i in left_list for j in right_list])
                elif input[index] == "-":
                    res.extend([i - j for i in left_list for j in right_list])
                else:
                    res.extend([i * j for i in left_list for j in right_list])
        return res


a = Solution()
print(a.diffWaysToCompute("2-1-1"))
print(a.diffWaysToCompute("2*3-4*5"))
print(a.diffWaysToCompute("10+5"))
